﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="cHead" ContentPlaceHolderID="cphHead" runat="server">
    <% this.Page.Title = (string)ViewData["PageTitle"]; %>
</asp:Content>

<asp:Content ID="cJScripts" ContentPlaceHolderID="cphJScripts" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            var newsA = $("#newsList dt a");
            var newsDD = $("#newsList dd");
            var tTimer = null;

            $("#newsList dt a").click(function () {
                var currentPos = newsA.index($(this));
                $("#newsList dt").removeClass("selected");
                $(this).parent("dt").addClass("selected");
                newsDD.hide();
                tTimer.stop();
                $(newsDD.eq(currentPos)).animate({ "opacity": "show" }, "slow");

                _gaq.push(['_trackEvent', 'News', 'Click', 'Home_News']);

                return false;
            });

            $(".js-lazyLoad").show().lazyload({
                effect: "fadeIn",
                load: function (elements_left, settings) {
                    $(".js-legend").fadeTo("slow", "1");
                }
            });

            LoadFeed();

            var iNewsDD = newsDD.length;
            var iCurrentNewsDD = 0;
            tTimer = $.timer(7000, function (timer) {
                iCurrentNewsDD++;
                iCurrentNewsDD = (iCurrentNewsDD == iNewsDD) ? 0 : iCurrentNewsDD;
                newsDD.hide();
                $("#newsList dt").removeClass("selected");
                $(newsA.eq(iCurrentNewsDD)).parent("dt").addClass("selected");
                $(newsDD.eq(iCurrentNewsDD)).animate({ "opacity": "show" }, "slow");
            });
        });
    </script>
    <script id="externalFeedTemplate" type="text/x-jquery-tmpl">
        <li><a href="${Link}" target="_blank">${$item.ConvertToDate($item)} - <strong>${Source}</strong> - ${Title}</a></li>
    </script>
</asp:Content>

<asp:Content ID="cMainContent" ContentPlaceHolderID="cphMainContent" runat="server">
    <div class="display">
    <%= ScoutNET.Resources.Home_Index_IntroText %>
    </div>
    
    <div class="boxLargeHome">
	    <div id="titleContent">
    	    <h1><%= ScoutNET.Resources.Home_Index_News %></h1>
        </div>
	
	    <dl id="newsList">
            <% for (int i = 0; i < ((List<tSite_New>)ViewData["News"]).Count; i++ ){ %>
            <dt class="<%= (i == 0) ? "selected" : "" %>">
                <%= Html.ActionLinkHtml(@"
                <span><img src=""" + ((List<tSite_New>)ViewData["News"])[i].tSite_Section.Logo + @""" alt=""" + ((List<tSite_New>)ViewData["News"])[i].SectionName + @""" /></span>
                <span>" + ((List<tSite_New>)ViewData["News"])[i].Title.ResizeText(37,"...") + "<br />" + ((List<tSite_New>)ViewData["News"])[i].InsertDate.ToString("dd/MM/yy") + " - <strong>" + ((List<tSite_New>)ViewData["News"])[i].SectionName + "</strong></span>", "Details", new { systemName = ((List<tSite_New>)ViewData["News"])[i].SystemName.UppercaseFirst(), controller = "News", ID = ((List<tSite_New>)ViewData["News"])[i].ID, Title = ((List<tSite_New>)ViewData["News"])[i].Title.ParseUrl() }, new { title = Html.Decode(((List<tSite_New>)ViewData["News"])[i].Title.ClearHTMLTags()) })%>
            </dt>
            <dd class="<%= (i > 0) ? "display" : "" %>">
                <h2><%= Html.ActionLink(((List<tSite_New>)ViewData["News"])[i].Title, "Details", new { systemName = ((List<tSite_New>)ViewData["News"])[i].SystemName.UppercaseFirst(), controller = "News", ID = ((List<tSite_New>)ViewData["News"])[i].ID, Title = ((List<tSite_New>)ViewData["News"])[i].Title.ParseUrl() }, new { title = Html.Decode(((List<tSite_New>)ViewData["News"])[i].Title.ClearHTMLTags()) })%></h2>
                <span class="postBy">
                    Postée le :  <%= ((List<tSite_New>)ViewData["News"])[i].InsertDate.ToString("dd/MM/yyyy")%> à <%= ((List<tSite_New>)ViewData["News"])[i].InsertDate.ToString("HH:mm")%> venant du <%= Html.ActionLink("staff " + ((List<tSite_New>)ViewData["News"])[i].SectionName, "Index", new { controller = "Staff", systemName = ((List<tSite_New>)ViewData["News"])[i].SystemName.UppercaseFirst() })%>
                </span>
                <%= ((List<tSite_New>)ViewData["News"])[i].News.ResizeText(300, Html.ActionLink(" Lire plus...", "Details", new { systemName = ((List<tSite_New>)ViewData["News"])[i].SystemName.UppercaseFirst(), controller = "News", ID = ((List<tSite_New>)ViewData["News"])[i].ID, Title = ((List<tSite_New>)ViewData["News"])[i].Title.ParseUrl() }).ToHtmlString()).ClearBreak() %>
            </dd>
            <% } %>
        </dl>
    </div>
    
    <div class="clr"></div>
    <hr />
    
    <div class="boxHome">
        <h1><%= ScoutNET.Resources.Home_Index_Meeting %></h1>
        
        <% if (((List<sp_Site_GetNextMeetingsResult>)ViewData["LatestEvents"]).Count > 0){ %>
            <ul id="date">
            <% foreach (sp_Site_GetNextMeetingsResult meeting in (List<sp_Site_GetNextMeetingsResult>)ViewData["LatestEvents"]) { %>
                <li>
                    <% if ((EventType)meeting.EventType != EventType.Respite){
                        if (meeting.EStartDate.ToString("dd/MM/yy") != meeting.EEndDate.ToString("dd/MM/yy")){ %>
                            <%= meeting.EStartDate.ToString("dd/MM/yy HH:mm")%> au <%= meeting.EEndDate.ToString("dd/MM/yy HH:mm")%>
                        <% }else{ %>
                            <%= meeting.EStartDate.ToString("dd/MM/yy")%> de <%= meeting.EStartDate.ToString("HH:mm")%> à <%= meeting.EEndDate.ToString("HH:mm")%>
                        <% } %> 
                    <% }else{ %>
                        <%= meeting.EStartDate.ToString("dd/MM/yy")%>
                    <% } %>
                     - <strong><%= meeting.Section%></strong> - <%= meeting.Title%>
                </li>
            <% } %>
            </ul>
        <% }else{ %>
            <%= Html.Encode(ScoutNET.Resources.Home_Index_NoMeeting) %>
        <% } %>
    </div>
    <div class="littleBoxHome">
	    <h1>Instant photo</h1>
	    <% if (((sp_Site_GetRandomImageResult)ViewData["RandomImg"]) != null) { %>
	    <div class="picture">
            <a href="<%= Url.Action("Index", "Photo", new { systemName = ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).SystemName.UppercaseFirst(), ID = ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).AID, Title = ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).AlbumName.ParseUrl(), page = ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).RowNumber }) %>">
                <img class="js-lazyLoad homePicture" title="<%= ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).AlbumName%>" alt="<%= ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).SectionName %> - <%= ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).AlbumName%>" src="/Design/Images/SiteImages/indicator.gif" data-original="<%= Html.ImageResizedUrl("Home", "ImageResize", ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).AlbumName.ParseUrl(), ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).ID) %>" />
            </a>
            <noscript>
                <%= Html.ActionLinkImage(((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).AlbumName, Html.ImageResizedUrl("Home", "ImageResize", ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).AlbumName, ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).ID) , "Index", new { controller = "Photo", systemName = ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).SystemName.UppercaseFirst(), ID = ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).AID, Title = ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).AlbumName.ParseUrl(), page = ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).RowNumber }, new { title = ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).AlbumName })%>
            </noscript>
        </div>
	    <div class="js-legend pictureLegend">
	        <strong><%= ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).SectionName %></strong><br/>
            <%= ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).AlbumName %>
        </div>
        <noscript class="pictureLegend">
            <strong><%= ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).SectionName %></strong><br/>
            <%= ((sp_Site_GetRandomImageResult)ViewData["RandomImg"]).AlbumName %>
        </noscript>
        <% } %>
    </div>
    
    <div class="clr"></div>
    <hr />
    
    <div class="boxHome loader" id="fedeList">
	    <h1><%= ScoutNET.Resources.Home_Index_NewsFede %></h1>
    </div>
    
    <div class="littleBoxHome">
        <h1><%= ScoutNET.Resources.Home_Index_Facebook %></h1>
        <div class="fb-like-box" data-href="http://www.facebook.com/uniteloverval" data-width="312" data-height="285" data-show-faces="true" data-border-color="#ffffff" data-stream="false" data-header="false"></div>
    </div>
    
    <div class="clr"></div>
</asp:Content>
